{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6092a10c",
   "metadata": {},
   "source": [
    "### 回顾上周内容\n",
    "* datetime\n",
    "* time\n",
    "* help()\n",
    "* **range()函数**\n",
    "* random模块\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "34f4dde6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 9, 13)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 调用模块\n",
    "import datetime\n",
    "\n",
    "# help(datetime) ←帮助可以知道此模块的所有方法和使用场景\n",
    "\n",
    "# datetime里面的date方法\n",
    "datetime.date.today()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "02fa45d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=9, tm_mday=13, tm_hour=15, tm_min=13, tm_sec=27, tm_wday=0, tm_yday=256, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "# 本地时间\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "30f027ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-10, -40, -70]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5, 10))\n",
    "[5, 6, 7, 8, 9]\n",
    "\n",
    "# list(range(0, 10, 3))  0指起点 10指终点 3指步长(step)即一次走3步\n",
    "# [0, 3, 6, 9]\n",
    "\n",
    "list(range(-10, -100, -30))\n",
    "[-10, -40, -70]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ec76bac",
   "metadata": {},
   "source": [
    "### 本周学习内容\n",
    "\n",
    "* 如果出现 **\"\"未被定义** 就先运行调用相关模块 \n",
    "* 先后顺序很重要！最好先import\n",
    "* 如果range里面只有一个数字的话，代表运行的次数。此外，计算机从0开始计算。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "59d8b3c0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "# 当只有一个数字的时候，代表需要循环的次数\n",
    "for i in range(5):\n",
    "     print(\"hello world!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cf1adea0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7407899402331845"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "# help(random)\n",
    "\n",
    "random.random() #从0-1生成随机数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a67f3261",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "172"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(99,999)  #指从99-999生成随机数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "821bf3c5",
   "metadata": {},
   "source": [
    "* for循环和range一起使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "434c5366",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xiaoming--2010130001\n",
      "qilin--2010130002\n",
      "kaijun--2010130003\n"
     ]
    }
   ],
   "source": [
    "names = [\"xiaoming\",\"qilin\",\"kaijun\"]\n",
    "\n",
    "# for i in names: 取到了names中的值（values）\n",
    "# for 遍历数据的重要操作\n",
    "# enumerate 枚举 产生steps的位置索引值（index）\n",
    "\n",
    "for k,i in enumerate(names):\n",
    "    print(i+\"--201013000\"+str(k+1))  #或者print(i=\"--\"+str(201013000+k+1))\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9cd21276",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
